package com.ssh.action;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.ssh.domain.Employee;
import com.ssh.service.EmployeeService;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

/**
 * Created by H-209-FX-XY on 2018/4/12.
 */
@Controller()//用于标注控制层组件（如struts中的action）
@Scope("prototype")//多列模式
@ParentPackage("struts-default")
@Namespace("/employee")
public class EmployeeAction  extends ActionSupport implements ModelDriven<Employee>{

    private Employee employee ;

    @Autowired
    EmployeeService employeeService;
    @Override
    public Employee getModel() {
        return employee;
    }
    @Action("employee_login")
    public void login(){
        employeeService.login(employee);
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }
}
